<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>个人存款计算</title>
		<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
		<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
		<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
	    <script>
	        function calc() {
				//alert("函数被调用了");
				mon=$("#money").val();//取得文本框用户输入的值"6000"
				monNum=parseInt(mon);//把字符串转成数字,monNum=6000
				var ban=0,total=0;
				yea=$("#year option:selected").text();
				if(yea=="一年"){
					ban=monNum*0.0175*1;
					total=ban+monNum;
				}
				if(yea=="二年"){
					ban=monNum*0.0225*2;
					total=ban+monNum;
				}
				if(yea=="三年"){
					ban=monNum*0.0275*3;
					total=ban+monNum;
				}
				if(yea=="四年"){
					ban=monNum*0.0275*4;
					total=ban+monNum;
				}
				if(yea=="五年"){
					ban=monNum*0.0275*5;
					total=ban+monNum;
				}
				$("#balance").val(ban);
				$("#total").val(total);
		    }
        </script>
	</head>
	<body>
		<div class="text-center center-block">
			<table class="table table-bordered">
				<tr class="bg-primary">
					<td colspan="2">个人存款计算器</td>
				</tr>
				<tr>
					<td>存款金额</td>
					<td>
						<input class="form-control" type="text" id="money">
					</td>
				</tr>
				<tr>
					<td>存款期限</td>
					<td>
						<select class="form-control" id="year">
							<option>一年</option>
							<option>二年</option>
							<option>三年</option>
							<option>四年</option>
							<option>五年</option>
						</select>
					</td>
				</tr>
				<tr>
					<td>所得利息</td>
					<td>
						<input class="form-control" readonly ="readonly" type="text" id="balance">
					</td>
				</tr>
				<tr>
					<td>本息合计</td>
					<td>
						<input class="form-control" readonly ="readonly" type="text" id="total">
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<button onclick="calc()" class="btn btn-danger">开始计算</button>
				    </td>
				</tr>
			</table>
		</div>
	</body>
</html>
